package com.caisejingyu.whales.mediator.main.service;

import android.support.annotation.NonNull;

import java.util.List;


/**
 * 服务管理工厂类
 */
@SuppressWarnings("unused")
public final class MediatorServiceFactory implements IServiceManager {

    private static final MediatorServiceFactory INSTANCE = new MediatorServiceFactory();

    private final IServiceManager mIServiceManagerDelegate;

    public static MediatorServiceFactory getInstance() {
        return INSTANCE;
    }

    private MediatorServiceFactory() {
        mIServiceManagerDelegate = ClassUtil.INSTANCE.newInstance(ServiceManagerImpl.class);
        init();
    }

    public void init() {}

    @Override
    public <T> T get(@NonNull Class<T> cls) {
        return mIServiceManagerDelegate.get(cls);
    }

    @Override
    public <T> List<T> getAll(@NonNull Class<T> cls) {
        return mIServiceManagerDelegate.getAll(cls);
    }

    @Override
    public <T, E extends T> IServiceManager put(@NonNull Class<T> cls, @NonNull Class<E> implClass) {
        mIServiceManagerDelegate.put(cls, implClass);
        return this;
    }

    @Override
    public <T, E extends T> boolean replace(@NonNull Class<T> cls, @NonNull Class<E> implClass) {
        return mIServiceManagerDelegate.replace(cls, implClass);
    }

    @Override
    public <T> boolean contains(@NonNull Class<T> cls) {
        return mIServiceManagerDelegate.contains(cls);
    }

    @Override
    public <T> void remove(@NonNull Class<T> cls) {
        mIServiceManagerDelegate.remove(cls);
    }

    @Override
    public void clear() {
        mIServiceManagerDelegate.clear();
    }
}
